package io.gbznt.modules.buss.service.impl;

import java.io.DataOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import io.gbznt.common.utils.Constant;
import io.gbznt.common.utils.DateUtils;
import io.gbznt.common.utils.PageUtils;
import io.gbznt.common.utils.Query;
import io.gbznt.common.utils.ShiroUtils;
import io.gbznt.config.SxbwAndDos;
import io.gbznt.config.TcpStartService;
import io.gbznt.modules.buss.constatnt.WindDirectionEnum;
import io.gbznt.modules.buss.dao.BussRtuRecordDao;
import io.gbznt.modules.buss.entity.BussFarmlandInfoEntity;
import io.gbznt.modules.buss.entity.BussMaintainTaskEntity;
import io.gbznt.modules.buss.entity.BussRtuEquipmentEntity;
import io.gbznt.modules.buss.entity.BussRtuInfoEntity;
import io.gbznt.modules.buss.entity.BussRtuRecordEntity;
import io.gbznt.modules.buss.entity.BussRtuWarningRecordEntity;
import io.gbznt.modules.buss.entity.BussRtuWarningRoleEntity;
import io.gbznt.modules.buss.service.BussFarmlandInfoService;
import io.gbznt.modules.buss.service.BussMaintainTaskService;
import io.gbznt.modules.buss.service.BussRtuEquipmentService;
import io.gbznt.modules.buss.service.BussRtuInfoService;
import io.gbznt.modules.buss.service.BussRtuRecordService;
import io.gbznt.modules.buss.service.BussRtuWarningRecordService;
import io.gbznt.modules.buss.service.BussRtuWarningRoleService;
import io.gbznt.modules.sys.service.SysDeptService;
import net.sf.json.JSONObject;

@Service("bussRtuRecordService")
public class BussRtuRecordServiceImpl extends ServiceImpl<BussRtuRecordDao, BussRtuRecordEntity>
		implements BussRtuRecordService {

	private static org.slf4j.Logger logger = LoggerFactory.getLogger(BussRtuRecordServiceImpl.class);

	@Autowired
	private BussFarmlandInfoService bussFarmlandInfoService;
	@Autowired
	private BussRtuInfoService BussRtuInfoService;
	@Autowired
	private BussRtuWarningRoleService bussRtuWarningRoleService;
	@Autowired
	private BussRtuWarningRecordService bussRtuWarningRecordService;
	@Autowired
	private BussRtuEquipmentService bussRtuEquipmentService;
	@Autowired
	private BussMaintainTaskService bussMaintainTaskService;
	@Autowired
	private BussRtuInfoService bussRtuInfoService;
	@Autowired
	private SysDeptService sysDeptService;

	@Override
	public PageUtils queryPage(Map<String, Object> params) {
		String name = (String) params.get("name");// 田块
		String time = (String) params.get("time");// 时间段
		String str1 = "";
		String str2 = "";
		if (StringUtils.isNotBlank(time)) {
			String[] strs = time.split(" - ");
			str1 = strs[0];
			str2 = strs[1];
		}
		IPage<BussRtuRecordEntity> page = this.page(new Query<BussRtuRecordEntity>().getPage(params),
				new QueryWrapper<BussRtuRecordEntity>().eq(StringUtils.isNotBlank(name), "farmland_info_id", name)
						.between(StringUtils.isNotBlank(time), "create_time", str1, str2)
						// 个人数据权限控制
						.in(!Constant.SUPER_ADMIN.equals(ShiroUtils.getUserId()), "dept_id",
								sysDeptService.getPermissionDeptIdsArr(true, true))
						.orderByDesc("update_time"));
		for (BussRtuRecordEntity bre : page.getRecords()) {
			if (bre != null && StringUtils.isNotBlank(bre.getFarmlandInfoId())) {
				BussFarmlandInfoEntity bfie = bussFarmlandInfoService.getById(bre.getFarmlandInfoId());
				bre.setTkName(bfie.getName());
			}
		}

		return new PageUtils(page);
	}

	/**
	 * 解析报文并添加到数据库
	 */
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * io.gbznt.modules.buss.service.BussRtuRecordService#addRtuRecord(java.lang.
	 * String[], java.lang.Integer, java.lang.String, java.io.DataOutputStream)
	 */
	@Override
	public boolean addRtuRecord(String[] baowen, Integer type, String bw, DataOutputStream dos, Integer count) {
		BussRtuRecordEntity rtuRecord = new BussRtuRecordEntity();

		// 原报文
		rtuRecord.setMessageCode(bw);

		// 创建时间
		rtuRecord.setUpdateTime(new Date());

		// 遥测站号
		if (!"FFFFFFFFFF".equals(baowen[3] + baowen[4] + baowen[5] + baowen[6] + baowen[7])) {
			rtuRecord.setZhanghao(baowen[3] + baowen[4] + baowen[5] + baowen[6] + baowen[7]);
		}

		// 报文特征
		if (!"FF".equals(baowen[10])) {
			rtuRecord.setBaowentype(baowen[10]);
		}

		// 报文流水号
		if (!"FFFF".equals(baowen[14] + baowen[15])) {
			rtuRecord.setLiushuihao(baowen[14] + baowen[15]);
		}

		// 发报时间
		String time = "20" + baowen[16] + "-" + baowen[17] + "-" + baowen[18] + " " + baowen[19] + ":" + baowen[20]
				+ ":" + baowen[21];
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			rtuRecord.setCreateTime(sdf.parse(time));
		} catch (java.text.ParseException e) {
			e.printStackTrace();
		}

		// 遥测站地址标识符
		if (!"FFFF".equals(baowen[22] + baowen[23])) {
			rtuRecord.setYczdz(baowen[22] + baowen[23]);
		}

		// Rtu
		if (!"FFFFFFFFFF".equals(baowen[24] + baowen[25] + baowen[26] + baowen[27] + baowen[28])) {
			rtuRecord.setRtu(baowen[24] + baowen[25] + baowen[26] + baowen[27] + baowen[28]);
		}

		// 田块,rtuId（根据rtu序列号查询rtu，再赋予田块）
		if (StringUtils.isNotBlank(rtuRecord.getRtu())) {
			QueryWrapper<BussRtuInfoEntity> rtuqw = new QueryWrapper<>();
			rtuqw.eq("serial_num", rtuRecord.getRtu());
			BussRtuInfoEntity rtu = bussRtuInfoService.getOne(rtuqw);
			if (null != rtu) {
				rtuRecord.setRtuId(rtu.getId());
				rtuRecord.setFarmlandInfoId(rtu.getFarmlandInfoId());
			}
		}

		boolean flag = false;
		if (type == 1) {// 遥测站定时报
			// 观测时间
			if (!"FFFFFFFFFF".equals(baowen[32] + baowen[33] + baowen[34] + baowen[35] + baowen[36])) {
				String shijian = "20" + baowen[32] + "-" + baowen[33] + "-" + baowen[34] + " " + baowen[35] + ":"
						+ baowen[36];
				rtuRecord.setGcsj(shijian);
			}

			// 日雨量
			if (!"FFFFFF".equals(baowen[39] + baowen[40] + baowen[41])) {
				String str1 = baowen[41].substring(0, 1);
				String str2 = baowen[41].substring(1, 2);

				String ryl = (baowen[39] + baowen[40] + str1 + "." + str2).replaceAll("^(0+)", "") + "mm";

				if (ryl.startsWith(".")) {
					ryl = 0 + ryl;
				}

				rtuRecord.setRyl(ryl);
			}

			// 累计雨量
			if (!"FFFFFF".equals(baowen[44] + baowen[45] + baowen[46])) {
				String str1 = baowen[46].substring(0, 1);
				String str2 = baowen[46].substring(1, 2);

				String ljyl = (baowen[44] + baowen[45] + str1 + "." + str2).replaceAll("^(0+)", "") + "mm";

				if (ljyl.startsWith(".")) {
					ljyl = 0 + ljyl;
				}

				rtuRecord.setLjjy(ljyl);
			}

			// 一号闸门
			if ("0100".equals(baowen[47] + baowen[48])) {
				rtuRecord.setGateA("关");
			} else if ("0101".equals(baowen[47] + baowen[48])) {
				rtuRecord.setGateA("开");
			}

			// 二号闸门
			if ("0200".equals(baowen[51] + baowen[52])) {
				rtuRecord.setGateB("关");
			} else if ("0201".equals(baowen[51] + baowen[52])) {
				rtuRecord.setGateB("开");
			}

			// 三号闸门
			if ("0300".equals(baowen[55] + baowen[56])) {
				rtuRecord.setGateC("关");
			} else if ("0301".equals(baowen[55] + baowen[56])) {
				rtuRecord.setGateC("开");
			}

			// 四号闸门
			if ("0400".equals(baowen[59] + baowen[60])) {
				rtuRecord.setGateD("关");
			} else if ("0401".equals(baowen[59] + baowen[60])) {
				rtuRecord.setGateD("开");
			}

			// 五号闸门
			if ("0500".equals(baowen[63] + baowen[64])) {
				rtuRecord.setGateE("关");
			} else if ("0501".equals(baowen[63] + baowen[64])) {
				rtuRecord.setGateE("开");
			}

			// 过闸累计流量，单位 m³/H
			// baowen[69]+baowen[70]+baowen[71]+baowen[72]+baowen[73]
			if (!"FFFFFFFFFF".equals(baowen[69] + baowen[70] + baowen[71] + baowen[72] + baowen[73])) {
				String str1 = baowen[72].substring(0, 1);
				String str2 = baowen[72].substring(1, 2);

				String shuiliuliang = (baowen[69] + baowen[70] + baowen[71] + str1 + "." + str2 + baowen[73] + "m³/H")
						.replaceAll("^(0+)", "");

				if (shuiliuliang.startsWith(".")) {
					shuiliuliang = 0 + shuiliuliang;
				}

				rtuRecord.setWaterDischarge(shuiliuliang);
			}

			// baowen[76] 风向
			if (!"FF".equals(baowen[76])) {
				int a = Integer.parseInt(baowen[76].replaceAll("^(0+)", ""));
				String fengxiang = WindDirectionEnum.getByValue(a).getDescription();
				rtuRecord.setWindDirection(fengxiang);// 风向
			}

			// 风速传感器
			if (!"FFFF".equals(baowen[77] + baowen[78])) {
				String str = (baowen[77] + baowen[78]).replaceAll("^(0+)", "") + "°";

				if (str.startsWith(".")) {
					str = 0 + str;
				}

				rtuRecord.setFscgq(str);
			}

			// baowen[79] 风速
			if (!"FF".equals(baowen[81])) {
				rtuRecord.setWindVelocity(baowen[81] + "级");// 风速
			}

			// 光照度
			if (!"FFFFFF".equals(baowen[84] + baowen[85] + baowen[86])) {
				String str = (baowen[84] + baowen[85] + baowen[86]).replaceAll("^(0+)", "");

				if (str.startsWith(".")) {
					str = 0 + str;
				}

				rtuRecord.setGzd(str);// 光照度
			}

			// 水温 baowen[82]+baowen[83]
			if (!"FFFF".equals(baowen[89] + baowen[90])) {
				String str1 = baowen[90].substring(0, 1);
				String str2 = baowen[90].substring(1, 2);
				String shuiwen = (baowen[89] + str1 + "." + str2).replaceAll("^(0+)", "") + "℃";

				if (shuiwen.startsWith(".")) {
					shuiwen = 0 + shuiwen;
				}

				rtuRecord.setWaterTemperature(shuiwen);
			}

			// 水位 baowen[86]+baowen[87]+baowen[88]+baowen[89]
			if (!"FFFFFFFF".equals(baowen[93] + baowen[94] + baowen[95] + baowen[96])) {
				String str1 = baowen[95].substring(0, 1);
				String str2 = baowen[95].substring(1, 2);
				String shuiwei = (baowen[93] + baowen[94] + str1 + "." + str2 + baowen[96]).replaceAll("^(0+)", "")
						+ "m";

				if (shuiwei.startsWith(".")) {
					shuiwei = 0 + shuiwei;
				}

				rtuRecord.setWaterDepth(shuiwei);
			}

			// 电池 baowen[92]+baowen[93]
			if (!"FFFF".equals(baowen[102] + baowen[103])) {
				String dianchi = (baowen[102] + "." + baowen[103]).replaceAll("^(0+)", "") + "V";

				if (dianchi.startsWith(".")) {
					dianchi = 0 + dianchi;
				}

				rtuRecord.setSolarCell(dianchi);
			}
		} else if (type == 2) {// 开关闸指令
			// 观测时间
			if (!"FFFFFFFFFF".equals(baowen[32] + baowen[33] + baowen[34] + baowen[35] + baowen[36])) {
				String shijian = "20" + baowen[32] + "-" + baowen[33] + "-" + baowen[34] + " " + baowen[35] + ":"
						+ baowen[36];

				if (shijian.startsWith(".")) {
					shijian = 0 + shijian;
				}

				rtuRecord.setGcsj(shijian);
			}
			// 一号闸门
			if ("0100".equals(baowen[37] + baowen[38])) {
				rtuRecord.setGateA("关");
			} else if ("0101".equals(baowen[37] + baowen[38])) {
				rtuRecord.setGateA("开");
			}

			// 二号闸门
			if ("0200".equals(baowen[41] + baowen[42])) {
				rtuRecord.setGateB("关");
			} else if ("0201".equals(baowen[41] + baowen[42])) {
				rtuRecord.setGateB("开");
			}

			// 三号闸门
			if ("0300".equals(baowen[45] + baowen[46])) {
				rtuRecord.setGateC("关");
			} else if ("0301".equals(baowen[45] + baowen[46])) {
				rtuRecord.setGateC("开");
			}

			// 四号闸门
			if ("0400".equals(baowen[49] + baowen[50])) {
				rtuRecord.setGateD("关");
			} else if ("0401".equals(baowen[49] + baowen[50])) {
				rtuRecord.setGateD("开");
			}

			// 五号闸门
			if ("0500".equals(baowen[53] + baowen[54])) {
				rtuRecord.setGateE("关");
			} else if ("0501".equals(baowen[53] + baowen[54])) {
				rtuRecord.setGateE("开");
			}

			// 电池 baowen[92]+baowen[93]
			if (!"FFFF".equals(baowen[59] + baowen[60])) {
				String dianchi = (baowen[59] + "." + baowen[60]).replaceAll("^(0+)", "") + "V";

				if (dianchi.startsWith(".")) {
					dianchi = 0 + dianchi;
				}

				rtuRecord.setSolarCell(dianchi);
			}

		} else if (type == 3) {// 中心站查询遥测站实时数据
			// 观测时间
			if (!"FFFFFFFFFF".equals(baowen[32] + baowen[33] + baowen[34] + baowen[35] + baowen[36])) {
				String shijian = "20" + baowen[32] + "-" + baowen[33] + "-" + baowen[34] + " " + baowen[35] + ":"
						+ baowen[36];

				rtuRecord.setGcsj(shijian);
			}

			// 一号闸门
			if ("0100".equals(baowen[37] + baowen[38])) {
				rtuRecord.setGateA("关");
			} else if ("0101".equals(baowen[37] + baowen[38])) {
				rtuRecord.setGateA("开");
			}

			// 二号闸门
			if ("0200".equals(baowen[41] + baowen[42])) {
				rtuRecord.setGateB("关");
			} else if ("0201".equals(baowen[41] + baowen[42])) {
				rtuRecord.setGateB("开");
			}

			// 三号闸门
			if ("0300".equals(baowen[45] + baowen[46])) {
				rtuRecord.setGateC("关");
			} else if ("0301".equals(baowen[45] + baowen[46])) {
				rtuRecord.setGateC("开");
			}

			// 四号闸门
			if ("0400".equals(baowen[49] + baowen[50])) {
				rtuRecord.setGateD("关");
			} else if ("0401".equals(baowen[49] + baowen[50])) {
				rtuRecord.setGateD("开");
			}

			// 五号闸门
			if ("0500".equals(baowen[53] + baowen[54])) {
				rtuRecord.setGateE("关");
			} else if ("0501".equals(baowen[53] + baowen[54])) {
				rtuRecord.setGateE("开");
			}

			// 水位 baowen[86]+baowen[87]+baowen[88]+baowen[89]
			if (!"FFFFFFFF".equals(baowen[59] + baowen[60] + baowen[61] + baowen[62])) {
				String str1 = baowen[61].substring(0, 1);
				String str2 = baowen[61].substring(1, 2);
				String shuiwei = (baowen[59] + baowen[60] + str1 + "." + str2 + baowen[62]).replaceAll("^(0+)", "")
						+ "m";
				if (shuiwei.startsWith(".")) {
					shuiwei = 0 + shuiwei;
				}

				rtuRecord.setWaterDepth(shuiwei);
			}

			// 电池 baowen[92]+baowen[93]
			if (!"FFFF".equals(baowen[65] + baowen[66])) {
				String dianchi = (baowen[65] + "." + baowen[66]).replaceAll("^(0+)", "") + "V";

				if (dianchi.startsWith(".")) {
					dianchi = 0 + dianchi;
				}
				rtuRecord.setSolarCell(dianchi);
			}
		} else if (type == 4) {// 中心站读取遥测站基本配置表/遥测站自报基本配置表
			// 定时报间隔
			if (!"FF".equals(baowen[31])) {
				String str = baowen[31].replaceAll("^(0+)", "") + "H";
				if (str.startsWith(".")) {
					str = 0 + str;
				}

				rtuRecord.setDsbjg(str);
			}

			// 日起始时间
			if (!"FF".equals(baowen[34])) {
				String str = baowen[34].replaceAll("^(0+)", "") + "点";
				if (str.startsWith(".")) {
					str = 0 + str;
				}

				rtuRecord.setRqqssj(str);
			}

			// 水位基值
			if (!"FFFF".equals(baowen[37] + baowen[38])) {
				String str1 = baowen[38].substring(0, 1);
				String str2 = baowen[38].substring(1, 2);

				String str = (baowen[37] + str1 + "." + str2).replaceAll("^(0+)", "") + "m";
				if (str.startsWith(".")) {
					str = 0 + str;
				}

				rtuRecord.setSwjz(str);
			}

			// 水位上限
			if (!"FFFF".equals(baowen[41] + baowen[42])) {
				String str1 = baowen[42].substring(0, 1);
				String str2 = baowen[42].substring(1, 2);

				String str = (baowen[41] + str1 + "." + str2).replaceAll("^(0+)", "") + "m";
				if (str.startsWith(".")) {
					str = 0 + str;
				}

				rtuRecord.setSwjz(str);
			}

			// 水位下限
			if (!"FFFF".equals(baowen[45] + baowen[46])) {
				String str1 = baowen[46].substring(0, 1);
				String str2 = baowen[46].substring(1, 2);

				String str = (baowen[45] + str1 + "." + str2).replaceAll("^(0+)", "") + "m";
				if (str.startsWith(".")) {
					str = 0 + str;
				}

				rtuRecord.setSwjz(str);
			}
		} else if (type == 5) {// 中心站修改遥测站运行参数配置表
			// 定时报间隔
			if (!"FF".equals(baowen[31])) {
				String str = baowen[31].replaceAll("^(0+)", "") + "H";
				if (str.startsWith(".")) {
					str = 0 + str;
				}

				rtuRecord.setDsbjg(str);
			}

			// 日起始时间
			if (!"FF".equals(baowen[34])) {
				String str = baowen[34].replaceAll("^(0+)", "") + "点";
				if (str.startsWith(".")) {
					str = 0 + str;
				}
				rtuRecord.setRqqssj(str);
			}

			// 水位基值
			if (!"FFFF".equals(baowen[37] + baowen[38])) {
				String str1 = baowen[38].substring(0, 1);
				String str2 = baowen[38].substring(1, 2);

				String str = (baowen[37] + str1 + "." + str2).replaceAll("^(0+)", "") + "m";
				if (str.startsWith(".")) {
					str = 0 + str;
				}

				rtuRecord.setSwjz(str);
			}

			// 水位上限
			if (!"FFFF".equals(baowen[41] + baowen[42])) {
				String str1 = baowen[42].substring(0, 1);
				String str2 = baowen[42].substring(1, 2);

				String str = (baowen[41] + str1 + "." + str2).replaceAll("^(0+)", "") + "m";
				if (str.startsWith(".")) {
					str = 0 + str;
				}

				rtuRecord.setSwjz(str);
			}

			// 水位下限
			if (!"FFFF".equals(baowen[45] + baowen[46])) {
				String str1 = baowen[46].substring(0, 1);
				String str2 = baowen[46].substring(1, 2);

				String str = (baowen[45] + str1 + "." + str2).replaceAll("^(0+)", "") + "m";
				if (str.startsWith(".")) {
					str = 0 + str;
				}

				rtuRecord.setSwjz(str);
			}
		} else {

		}
		// 添加上行报文
		flag = this.save(rtuRecord);
		// 根据报文触发预警规则添加告警记录
		this.addGjjlByBw(rtuRecord);

		if (count == 1) {
			// 上行报文与输出流的类，并加入队列
			SxbwAndDos sad = new SxbwAndDos();
			sad.setSxbw(rtuRecord);
			sad.setDos(dos);
			TcpStartService.SXBW_DOS_QUEUE_ljc.offer(sad);

			// 定时报的回馈下行报文

			// 发报时间 15 10 16 14 58 38
			Date date = new Date();
			String dateStr = new SimpleDateFormat("yy MM dd HH mm ss").format(date);
			// rtu序列号 baowen[24] + baowen[25] + baowen[26] + baowen[27] + baowen[28]
			// 密码 baowen[8]+baowen[9]
			String str = "7E 7E " + baowen[24] + " " + baowen[25] + " " + baowen[26] + " " + baowen[27] + " "
					+ baowen[28] + " 01 " + baowen[8] + " " + baowen[9] + " 34 80 08 02 00 1F " + dateStr + " 03 0A 72";
			byte[] btyeSend = TcpStartService.hexStrToByteArrs(str);
			try {
				dos.write(btyeSend, 0, btyeSend.length);
				logger.info("返回校时报：" + str);
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
		if (rtuRecord.getBaowentype().equals("4E") || rtuRecord.getBaowentype().equals("42")) {
			// 上行报文与输出流的类，并加入队列
			SxbwAndDos sad = new SxbwAndDos();
			sad.setSxbw(rtuRecord);
			sad.setDos(dos);
			TcpStartService.SXBW_DOS_QUEUE.offer(sad);
		}

		// 启动RTU获取下行报文线程
		// new Thread(new RtuReadSendRunsFs(rtuRecord)).start();

		return flag;
	}

	/**
	 * 根据报文触发预警规则添加告警记录
	 */
	@Override
	public boolean addGjjlByBw(BussRtuRecordEntity rtuRecord) {
		boolean flag = false;

		// 根据rtu序列号获取rtu信息
		QueryWrapper<BussRtuInfoEntity> rtuqw = new QueryWrapper<>();
		rtuqw.eq("serial_num", rtuRecord.getRtu());
		BussRtuInfoEntity rtu = BussRtuInfoService.getOne(rtuqw);
		if (null == rtu) {
			return false;
		}

		// 根据rtu的田块查询出所有的告警规则
		QueryWrapper<BussRtuWarningRoleEntity> gjgzqw = new QueryWrapper<>();
		gjgzqw.like("relation_farmland_ids", rtu.getFarmlandInfoId());
		List<BussRtuWarningRoleEntity> gjgzList = bussRtuWarningRoleService.list(gjgzqw);

		// 查询出rtu的田块
		BussFarmlandInfoEntity tiankuai = bussFarmlandInfoService.getById(rtu.getFarmlandInfoId());

		// 报文记录触发告警规则
		for (BussRtuWarningRoleEntity gjgz : gjgzList) {
			String str = gjgz.getYjgzJson();
			List<Map<String, Object>> listObjectFir = (List<Map<String, Object>>) JSONArray.parse(str);
			for (Map<String, Object> map : listObjectFir) {
				// net.sf.json.JSONObject 将Map转换为JSON方法
				JSONObject json = JSONObject.fromObject(map);

				// 先查询该类型下是否有相同的告警记录
				Map<String, Object> gjjlMap = new HashMap<>();
				gjjlMap.put("tkId", rtu.getFarmlandInfoId());
				gjjlMap.put("yjgzId", gjgz.getId());
				gjjlMap.put("strJson", json.toString());
				gjjlMap.put("rtuId", rtu.getId());
				List<BussRtuWarningRecordEntity> gjjlList = bussRtuWarningRecordService.getGjjlMax(gjjlMap);
				SimpleDateFormat sdf = new SimpleDateFormat("HH");// 只有时
				// 只有当延时时间小于当前时间与创建时间的时间差时，才走修改操作
				if (gjjlList.size() > 0 && gjjlList.get(0).getSleepTime() != null
						&& (Integer.parseInt(sdf.format(new Date()))
								- Integer.parseInt(sdf.format(gjjlList.get(0).getCreateTime()))) < gjjlList.get(0)
										.getSleepTime()) {
					// 开始添加告警记录(4种类型公共数据)
					BussRtuWarningRecordEntity gjjl = gjjlList.get(0);
					gjjl.setRtuId(rtu.getId());// rtu id
					gjjl.setDeptId(rtu.getDeptId());// 部门id
					gjjl.setFarmlandInfoId(rtu.getFarmlandInfoId());// 田块id
					gjjl.setWarningRoleId(gjgz.getId());// 预警规则
					gjjl.setReceiveD(null == tiankuai ? "" : tiankuai.getHandler());// 接收人id（田块负责人）
					gjjl.setCreateTime(new Date());// 创建时间
					gjjl.setWarningText(gjgz.getYujingyu());// 告警语
					gjjl.setGjjlJson(json.toString());
					gjjl.setWarningNum(gjjl.getWarningNum() + 1);// 告警次数

					// String ss = (String) map.get("lowest");
					// 预警最低值
					Double min = Double.valueOf(map.get("lowest").toString());
					// 预警最高值
					Double max = Double.valueOf(map.get("lowest").toString());

					if (gjgz.getType() == 0) {// 田间水位
						// 根据rtu序列号获取设备
						QueryWrapper<BussRtuEquipmentEntity> shebeiqw = new QueryWrapper<>();
						shebeiqw.eq("rtu_id", rtu.getId());
						shebeiqw.eq("type", 1);
						List<BussRtuEquipmentEntity> shebeiList = bussRtuEquipmentService.list(shebeiqw);
						if (shebeiList.size() > 0) {// 如果查询到该rtu下存在设备
							BussRtuEquipmentEntity shebei = shebeiList.get(0);// 则取第一个设备
							gjjl.setEquipmentId(shebei.getId());// 设备id
						}

						// 水位
						String waterDepth = rtuRecord.getWaterDepth();
						String str1 = waterDepth.substring(0, waterDepth.indexOf("m"));// 截取m之前的字符串

						if (str1.contains("C")) {
							gjjl.setWarningType(4);// 告警类型（设备报警）
							flag = bussRtuWarningRecordService.updateById(gjjl);// 添加告警记录
							// this.addGdByGjjl(gjjl, map.get("id"), 1);// 添加工单
						} else {
							Double shuiwei = Double.valueOf(str1);
							if (shuiwei > max || shuiwei < min) {// 触发告警规则
								gjjl.setWarningValue(waterDepth);// 警告数值
								gjjl.setWarningType(0);// 告警类型
								flag = bussRtuWarningRecordService.updateById(gjjl);// 添加告警记录
								// this.addGdByGjjl(gjjl, map.get("id"), 0);// 添加工单
							}
						}
					}
					if (gjgz.getType() == 1) {// 田间水温
						// 根据rtu序列号获取设备
						QueryWrapper<BussRtuEquipmentEntity> shebeiqw = new QueryWrapper<>();
						shebeiqw.eq("rtu_id", rtu.getId());
						shebeiqw.eq("type", 6);
						List<BussRtuEquipmentEntity> shebeiList = bussRtuEquipmentService.list(shebeiqw);
						if (shebeiList.size() > 0) {// 如果查询到该rtu下存在设备
							BussRtuEquipmentEntity shebei = shebeiList.get(0);// 则取第一个设备
							gjjl.setEquipmentId(shebei.getId());// 设备id
						}

						// 水温
						String waterTemperature = rtuRecord.getWaterTemperature();

						if (StringUtils.isNotBlank(waterTemperature)) {
							String str1 = waterTemperature.substring(0, waterTemperature.indexOf("℃"));// 截取℃之前的字符串

							if (str1.contains("C")) {
								gjjl.setWarningType(4);// 告警类型（设备报警）
								flag = bussRtuWarningRecordService.updateById(gjjl);// 添加告警记录
								// this.addGdByGjjl(gjjl, map.get("id"), 1);// 添加工单
							} else {
								Double shuiwei = Double.valueOf(str1);
								if (shuiwei > max || shuiwei < min) {// 触发告警规则
									gjjl.setWarningValue(waterTemperature);// 警告数值
									gjjl.setWarningType(1);// 告警类型
									flag = bussRtuWarningRecordService.updateById(gjjl);// 添加告警记录
									// this.addGdByGjjl(gjjl, map.get("id"), 0);// 添加工单
								}
							}
						}
					}
					if (gjgz.getType() == 2) {// 风力风向
						// 根据rtu序列号获取设备
						QueryWrapper<BussRtuEquipmentEntity> shebeiqw = new QueryWrapper<>();
						shebeiqw.eq("rtu_id", rtu.getId());
						shebeiqw.eq("type", 3);
						List<BussRtuEquipmentEntity> shebeiList = bussRtuEquipmentService.list(shebeiqw);
						if (shebeiList.size() > 0) {// 如果查询到该rtu下存在设备
							BussRtuEquipmentEntity shebei = shebeiList.get(0);// 则取第一个设备
							gjjl.setEquipmentId(shebei.getId());// 设备id
						}

						// 风力风向
						String windVelocity = rtuRecord.getWindVelocity();
						if (StringUtils.isNotBlank(windVelocity)) {
							String str1 = windVelocity.replaceAll("^(0+)", "");// 截取℃之前的字符串

							if (str1.contains("C")) {
								gjjl.setWarningType(4);// 告警类型（设备报警）
								flag = bussRtuWarningRecordService.updateById(gjjl);// 添加告警记录
								// this.addGdByGjjl(gjjl, map.get("id"), 1);// 添加工单
							} else {
								Double shuiwei = Double.valueOf(str1);
								if (shuiwei > max || shuiwei < min) {// 触发告警规则
									gjjl.setWarningValue(windVelocity);// 警告数值
									gjjl.setWarningType(2);// 告警类型
									flag = bussRtuWarningRecordService.updateById(gjjl);// 添加告警记录
									// this.addGdByGjjl(gjjl, map.get("id"), 0);// 添加工单
								}
							}
						}
					}
					if (gjgz.getType() == 3) {// 电池
						// 根据rtu序列号获取设备
						QueryWrapper<BussRtuEquipmentEntity> shebeiqw = new QueryWrapper<>();
						shebeiqw.eq("rtu_id", rtu.getId());
						shebeiqw.eq("type", 5);
						List<BussRtuEquipmentEntity> shebeiList = bussRtuEquipmentService.list(shebeiqw);
						if (shebeiList.size() > 0) {// 如果查询到该rtu下存在设备
							BussRtuEquipmentEntity shebei = shebeiList.get(0);// 则取第一个设备
							gjjl.setEquipmentId(shebei.getId());// 设备id
						}

						// 电池
						String solarCell = rtuRecord.getSolarCell();
						if (StringUtils.isNotBlank(solarCell)) {
							String str1 = solarCell.substring(0, solarCell.indexOf("V"));// 截取℃之前的字符串
							if (str1.contains("C")) {
								gjjl.setWarningType(4);// 告警类型（设备报警）
								flag = bussRtuWarningRecordService.updateById(gjjl);// 添加告警记录
								// this.addGdByGjjl(gjjl, map.get("id"), 1);// 添加工单
							} else {
								Double shuiwei = Double.valueOf(str1);
								if (shuiwei > max || shuiwei < min) {// 触发告警规则
									gjjl.setWarningValue(solarCell);// 警告数值
									gjjl.setWarningType(3);// 告警类型
									flag = bussRtuWarningRecordService.updateById(gjjl);// 添加告警记录
									// this.addGdByGjjl(gjjl, map.get("id"), 0);// 添加工单
								}
							}
						}
					}
					if (gjgz.getType() == 4) {// 光传感器
						// 根据rtu序列号获取设备
						QueryWrapper<BussRtuEquipmentEntity> shebeiqw = new QueryWrapper<>();
						shebeiqw.eq("rtu_id", rtu.getId());
						shebeiqw.eq("type", 7);
						List<BussRtuEquipmentEntity> shebeiList = bussRtuEquipmentService.list(shebeiqw);
						if (shebeiList.size() > 0) {// 如果查询到该rtu下存在设备
							BussRtuEquipmentEntity shebei = shebeiList.get(0);// 则取第一个设备
							gjjl.setEquipmentId(shebei.getId());// 设备id
						}

						// 光传感器
						String gcgq = rtuRecord.getGzd();
						if (StringUtils.isNotBlank(gcgq)) {
							if (gcgq.contains("C")) {
								gjjl.setWarningType(4);// 告警类型（设备报警）
								flag = bussRtuWarningRecordService.updateById(gjjl);// 添加告警记录
								// this.addGdByGjjl(gjjl, map.get("id"), 1);// 添加工单
							} else {
								Double shuiwei = Double.valueOf(gcgq);
								if (shuiwei > max || shuiwei < min) {// 触发告警规则
									gjjl.setWarningValue(gcgq);// 警告数值
									gjjl.setWarningType(3);// 告警类型
									flag = bussRtuWarningRecordService.updateById(gjjl);// 添加告警记录
									// this.addGdByGjjl(gjjl, map.get("id"), 0);// 添加工单
								}
							}
						}
					}
				} else {
					// 开始添加告警记录(4种类型公共数据)
					// 开始添加告警记录(4种类型公共数据)
					BussRtuWarningRecordEntity gjjl = new BussRtuWarningRecordEntity();
					gjjl.setRtuId(rtu.getId());// rtu id
					gjjl.setDeptId(rtu.getDeptId());// 部门id
					gjjl.setFarmlandInfoId(rtu.getFarmlandInfoId());// 田块id
					gjjl.setWarningRoleId(gjgz.getId());// 预警规则
					gjjl.setReceiveD(null == tiankuai ? "" : tiankuai.getHandler());// 接收人id（田块负责人）
					gjjl.setCreateTime(new Date());// 创建时间
					gjjl.setWarningText(gjgz.getYujingyu());// 告警语

					gjjl.setGjjlJson(json.toString());

					// 预警最低值
					Double min = Double.valueOf(map.get("lowest").toString());
					// 预警最高值
					Double max = Double.valueOf(map.get("highest").toString());

					if (gjgz.getType() == 0) {// 田间水位
						// 根据rtu序列号获取设备
						QueryWrapper<BussRtuEquipmentEntity> shebeiqw = new QueryWrapper<>();
						shebeiqw.eq("rtu_id", rtu.getId());
						shebeiqw.eq("type", 1);
						List<BussRtuEquipmentEntity> shebeiList = bussRtuEquipmentService.list(shebeiqw);
						if (shebeiList.size() > 0) {// 如果查询到该rtu下存在设备
							BussRtuEquipmentEntity shebei = shebeiList.get(0);// 则取第一个设备
							gjjl.setEquipmentId(shebei.getId());// 设备id
						}

						// 水位
						String waterDepth = rtuRecord.getWaterDepth();
						String str1 = waterDepth.substring(0, waterDepth.indexOf("m"));// 截取m之前的字符串

						if (str1.contains("C")) {
							gjjl.setWarningType(4);// 告警类型（设备报警）
							flag = bussRtuWarningRecordService.save(gjjl);// 添加告警记录
							// this.addGdByGjjl(gjjl, map.get("id"), 1);// 添加工单
						} else {
							Double shuiwei = Double.valueOf(str1);
							if (shuiwei > max || shuiwei < min) {// 触发告警规则
								gjjl.setWarningValue(waterDepth);// 警告数值
								gjjl.setWarningType(0);// 告警类型
								flag = bussRtuWarningRecordService.save(gjjl);// 添加告警记录
								// this.addGdByGjjl(gjjl, map.get("id"), 0);// 添加工单
							}
						}
					}
					if (gjgz.getType() == 1) {// 田间水温
						// 根据rtu序列号获取设备
						QueryWrapper<BussRtuEquipmentEntity> shebeiqw = new QueryWrapper<>();
						shebeiqw.eq("rtu_id", rtu.getId());
						shebeiqw.eq("type", 6);
						List<BussRtuEquipmentEntity> shebeiList = bussRtuEquipmentService.list(shebeiqw);
						if (shebeiList.size() > 0) {// 如果查询到该rtu下存在设备
							BussRtuEquipmentEntity shebei = shebeiList.get(0);// 则取第一个设备
							gjjl.setEquipmentId(shebei.getId());// 设备id
						}

						// 水温
						String waterTemperature = rtuRecord.getWaterTemperature();

						if (StringUtils.isNotBlank(waterTemperature)) {
							String str1 = waterTemperature.substring(0, waterTemperature.indexOf("℃"));// 截取℃之前的字符串

							if (str1.contains("C")) {
								gjjl.setWarningType(4);// 告警类型（设备报警）
								flag = bussRtuWarningRecordService.save(gjjl);// 添加告警记录
								// this.addGdByGjjl(gjjl, map.get("id"), 1);// 添加工单
							} else {
								Double shuiwei = Double.valueOf(str1);
								if (shuiwei > max || shuiwei < min) {// 触发告警规则
									gjjl.setWarningValue(waterTemperature);// 警告数值
									gjjl.setWarningType(1);// 告警类型
									flag = bussRtuWarningRecordService.save(gjjl);// 添加告警记录
									// this.addGdByGjjl(gjjl, map.get("id"), 0);// 添加工单
								}
							}
						}
					}
					if (gjgz.getType() == 2) {// 风力风向
						// 根据rtu序列号获取设备
						QueryWrapper<BussRtuEquipmentEntity> shebeiqw = new QueryWrapper<>();
						shebeiqw.eq("rtu_id", rtu.getId());
						shebeiqw.eq("type", 3);
						List<BussRtuEquipmentEntity> shebeiList = bussRtuEquipmentService.list(shebeiqw);
						if (shebeiList.size() > 0) {// 如果查询到该rtu下存在设备
							BussRtuEquipmentEntity shebei = shebeiList.get(0);// 则取第一个设备
							gjjl.setEquipmentId(shebei.getId());// 设备id
						}

						// 风力风向
						String windVelocity = rtuRecord.getWindVelocity();
						if (StringUtils.isNotBlank(windVelocity)) {
							String str1 = windVelocity.replaceAll("^(0+)", "");// 截取℃之前的字符串

							if (str1.contains("C")) {
								gjjl.setWarningType(4);// 告警类型（设备报警）
								flag = bussRtuWarningRecordService.save(gjjl);// 添加告警记录
								// this.addGdByGjjl(gjjl, map.get("id"), 1);// 添加工单
							} else {
								Double shuiwei = Double.valueOf(str1);
								if (shuiwei > max || shuiwei < min) {// 触发告警规则
									gjjl.setWarningValue(windVelocity);// 警告数值
									gjjl.setWarningType(2);// 告警类型
									flag = bussRtuWarningRecordService.save(gjjl);// 添加告警记录
									// this.addGdByGjjl(gjjl, map.get("id"), 0);// 添加工单
								}
							}
						}
					}
					if (gjgz.getType() == 3) {// 电池
						// 根据rtu序列号获取设备
						QueryWrapper<BussRtuEquipmentEntity> shebeiqw = new QueryWrapper<>();
						shebeiqw.eq("rtu_id", rtu.getId());
						shebeiqw.eq("type", 5);
						List<BussRtuEquipmentEntity> shebeiList = bussRtuEquipmentService.list(shebeiqw);
						if (shebeiList.size() > 0) {// 如果查询到该rtu下存在设备
							BussRtuEquipmentEntity shebei = shebeiList.get(0);// 则取第一个设备
							gjjl.setEquipmentId(shebei.getId());// 设备id
						}

						// 电池
						String solarCell = rtuRecord.getSolarCell();
						if (StringUtils.isNotBlank(solarCell)) {
							String str1 = solarCell.substring(0, solarCell.indexOf("V"));// 截取℃之前的字符串
							if (str1.contains("C")) {
								gjjl.setWarningType(4);// 告警类型（设备报警）
								flag = bussRtuWarningRecordService.save(gjjl);// 添加告警记录
								// this.addGdByGjjl(gjjl, map.get("id"), 1);// 添加工单
							} else {
								Double shuiwei = Double.valueOf(str1);
								if (shuiwei > max || shuiwei < min) {// 触发告警规则
									gjjl.setWarningValue(solarCell);// 警告数值
									gjjl.setWarningType(3);// 告警类型
									flag = bussRtuWarningRecordService.save(gjjl);// 添加告警记录
									// this.addGdByGjjl(gjjl, map.get("id"), 0);// 添加工单
								}
							}
						}
					}
				}

			}

		}
		return flag;
	}

	/**
	 * 根据报警记录而添加工单(告警记录实体类，告警级别字典id，工单类型)
	 */
	@Override
	public boolean addGdByGjjl(BussRtuWarningRecordEntity gjjl, String gjjb, Integer type) {
		boolean flag = false;
		BussMaintainTaskEntity gongdan = new BussMaintainTaskEntity();

		// 生成工号
		String ymdStr = DateUtils.format(new Date(), "yyyyMMdd");// 年月日
		String businessNum = ymdStr + "G0001";
		BussMaintainTaskEntity lastBussMaintainTaskEntity = bussMaintainTaskService
				.getOne(new QueryWrapper<BussMaintainTaskEntity>().select("max(business_num) as business_num")
						.like("business_num", ymdStr));
		if (null != lastBussMaintainTaskEntity) {
			String lastNumStr = lastBussMaintainTaskEntity.getBusinessNum().substring(9);
			Integer lastNum = Integer.valueOf(lastNumStr) + 1;
			businessNum = ymdStr + "G" + String.format("%04d", lastNum);
		}
		gongdan.setBusinessNum(businessNum);

		gongdan.setDeptId(gjjl.getDeptId());// 部门
		gongdan.setCreateId(Constant.SUPER_ADMIN);// 创建人
		gongdan.setCreateTime(new Date());// 创建时间
		gongdan.setFarmlandInfoId(gjjl.getFarmlandInfoId());// 田块
		gongdan.setHandler(gjjl.getReceiveD());// 处理人
		gongdan.setEquipmentId(gjjl.getEquipmentId());// 设备
		gongdan.setGradeNum(gjjb);// 紧急程度，告警级别，字典
		gongdan.setType(type);// 工单类型
		gongdan.setStatus(0);// 状态
		gongdan.setSourceType(0);// 来源类型
		gongdan.setContent(gjjl.getWarningText());// 工单内容
		gongdan.setWarningRecordId(gjjl.getId());// 告警记录id
		flag = bussMaintainTaskService.save(gongdan);// 添加工单
		return flag;
	}

	@Override
	public List<BussRtuRecordEntity> queryPagetotal(Map<String, Object> params) {
		String name = (String) params.get("name");// 田块
		String time = (String) params.get("time");// 时间段
		if (StringUtils.isBlank(time)) {
			Date date = new Date();// 取时间
			Calendar calendar = new GregorianCalendar();
			calendar.setTime(date);
			calendar.add(Calendar.DATE, -1);// 把日期往后增加一天.整数往后推,负数往前移动
			date = calendar.getTime(); // 这个时间就是日期往后推一天的结果
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
			String dateString = formatter.format(date);
			System.out.println(dateString);
			time = dateString + " 00:00:00 - " + dateString + " 23:59:59";
		}
		String str1 = "";
		String str2 = "";
		if (StringUtils.isNotBlank(time)) {
			String[] strs = time.split(" - ");
			str1 = strs[0];
			str2 = strs[1];
		}
		// 最远时间
		BussRtuRecordEntity zuiy = this.getOne(
				new QueryWrapper<BussRtuRecordEntity>().eq(StringUtils.isNotBlank(name), "farmland_info_id", name)
						.between(StringUtils.isNotBlank(time), "create_time", str1, str2)
						// 个人数据权限控制
						.orderByDesc("create_time").last("LIMIT 1"));
		// 最近时间
		BussRtuRecordEntity zuij = this.getOne(
				new QueryWrapper<BussRtuRecordEntity>().eq(StringUtils.isNotBlank(name), "farmland_info_id", name)
						.between(StringUtils.isNotBlank(time), "create_time", str1, str2)
						// 个人数据权限控制
						.orderByAsc("create_time").last("LIMIT 1"));
		List<BussRtuRecordEntity> lb = new ArrayList<>();
		if (zuij != null && zuiy != null) {
			lb.add(zuij);
			lb.add(zuiy);
		}

		return lb;
	}

	@Override
	public List<BussRtuRecordEntity> queryPagetotal12(Map<String, Object> params) {
		Calendar date = Calendar.getInstance();

		String year = String.valueOf(date.get(Calendar.YEAR));
		// 1月
		BussRtuRecordEntity yy = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-01-01 00:00:00", year + "-01-31 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));
		// 2月
		BussRtuRecordEntity ey = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-02-01 00:00:00", year + "-02-30 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));
		// 1月
		BussRtuRecordEntity sy = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-03-01 00:00:00", year + "-03-31 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));
		// 1月
		BussRtuRecordEntity sfoury = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-04-01 00:00:00", year + "-04-31 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));
		// 1月
		BussRtuRecordEntity wy = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-05-01 00:00:00", year + "-05-31 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));
		// 1月
		BussRtuRecordEntity ly = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-06-01 00:00:00", year + "-06-31 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));
		// 1月
		BussRtuRecordEntity qy = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-07-01 00:00:00", year + "-07-31 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));
		// 1月
		BussRtuRecordEntity by = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-08-01 00:00:00", year + "-08-31 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));
		// 1月
		BussRtuRecordEntity jy = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-09-01 00:00:00", year + "-09-31 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));
		// 1月
		BussRtuRecordEntity shiy = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-10-01 00:00:00", year + "-10-31 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));
		// 1月
		BussRtuRecordEntity shiyy = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-11-01 00:00:00", year + "-11-31 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));
		// 1月
		BussRtuRecordEntity shiey = this.getOne(new QueryWrapper<BussRtuRecordEntity>()
				.between("create_time", year + "-12-01 00:00:00", year + "-12-31 23:59:59").orderByDesc("create_time")
				.last("LIMIT 1"));

		List<BussRtuRecordEntity> lb = new ArrayList<>();
		lb.add(yy);
		lb.add(ey);
		lb.add(sy);
		lb.add(sfoury);
		lb.add(wy);
		lb.add(ly);
		lb.add(qy);
		lb.add(by);
		lb.add(jy);
		lb.add(shiy);
		lb.add(shiyy);
		lb.add(shiey);

		return lb;
	}

	@Override
	public List<BussRtuRecordEntity> getSxbw() {

		List<BussRtuRecordEntity> list = baseMapper.getSxbw();

		return list;
	}
}
